package 方法的引用;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;

public class 引用静态方法 {
    public static void main(String[] args) {
//        "1","2","3","4","5"
        //创建集合,添加元素
        ArrayList<String> str=new ArrayList<>();
        Collections.addAll(str,"1","2","3","4","5");

        //2.把上面的数字变成int

        List<Integer> list = str.stream().
                map(new Function<String, Integer>() {
                    @Override
                    public Integer apply(String s) {
                        return Integer.parseInt(s);
                    }
                }).toList();
        System.out.println(list);
        //方法引用
        str.stream().map(Integer::parseInt).forEach(System.out::println);
    }
}
